

package net.betou.trade.main.manager.impl;

import java.util.List;

import net.betou.common.hibernate3.Updater;
import net.betou.trade.entity.main.SuggestionType;
import net.betou.trade.main.dao.SuggestionTypeDao;
import net.betou.trade.main.manager.SuggestionTypeMng;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 
 * @author O.Y.
 */
@Service
@Transactional
public class SuggestionTypeMngImpl implements SuggestionTypeMng{

	public SuggestionType deleteById( Integer id ) {
		return dao.deleteById( id );
	}

	public SuggestionType [ ] deleteByIds( Integer [ ] ids ) {
		SuggestionType [ ] beans = new SuggestionType [ ids.length ];

		for ( int i = 0; i < ids.length; i++ ){
			beans[ i ] = dao.deleteById( ids[ i ] );
		}
		return beans;
	}

	@Transactional( readOnly = true )
	public SuggestionType findById( Integer id ) {
		return dao.findById( id );
	}

	public SuggestionType save( SuggestionType bean ) {
		return dao.save( bean );
	}

	public SuggestionType update( SuggestionType bean ) {
		
		Updater< SuggestionType > updater = new Updater< SuggestionType >( bean, Updater.UpdateMode.MIN );
		
		updater.include( "name" );
		updater.include( "description" );
		updater.include( "sort" );

		return dao.updateByUpdater( updater );
	}
	
	@Transactional( readOnly = true )
	public List<SuggestionType> findList() {
		return dao.findList(null, null);
	}
	
	@Transactional( readOnly = true )
	public List<SuggestionType> findList(String orderProperty, String orderDirection) {
		return dao.findList(orderProperty, orderDirection);
	}
	
	@Autowired
	private SuggestionTypeDao dao;

}
